//
//  OnionCertificationTwoController.m
//  OnionHome
//
//  Created by fengjie on 2019/10/2.
//  Copyright © 2019 FengJie. All rights reserved.
//

#import "OnionCertificationTwoController.h"
#import "IDCardCertificationCell.h"
#import "OnionCertificationCell.h"

@interface OnionCertificationTwoController ()<UITableViewDelegate,UITableViewDataSource>
/**listView*/
@property (nonatomic,strong)UITableView*listView;
@end

@implementation OnionCertificationTwoController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"葱花认证";
    [self.view addSubview:self.listView];
    
    [self.listView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(0);
    }];
}
#pragma mark UITableViewDelegate,UITableViewDataSource
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 3;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 2) {
        return 2;
    }
    return 1;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 0.01f;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 8.0f;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    return UIView.new;
}
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    return UIView.new;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    OnionCertificationUserCell * oneCell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([OnionCertificationUserCell class])];
    IDCardCertificationCell * twoCell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([IDCardCertificationCell class])];
    OnionCertificationProgressCell * thereCell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([OnionCertificationProgressCell class])];
    if (indexPath.section == 1) {
        twoCell.onionDic = @{@"leftName":@"身份认证",@"rightName":@"已完成"};
        return twoCell;
    }
    if (indexPath.section == 2 && indexPath.row == 0 ) {
        twoCell.onionDic = @{@"leftName":@"兴趣认证",@"rightName":@"编辑"};
        return twoCell;
    }
    if (indexPath.section == 2 && indexPath.row == 1) {
        return thereCell;
    }

    return oneCell;
}
-(UITableView*)listView{
    if(!_listView){
        _listView=[[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
        _listView.delegate= self;
        _listView.dataSource = self;
        
        _listView.rowHeight = UITableViewAutomaticDimension;
        _listView.estimatedRowHeight = 44.0f;
        
        [_listView registerClass:[OnionCertificationUserCell class] forCellReuseIdentifier:NSStringFromClass([OnionCertificationUserCell class])];

        [_listView registerClass:[IDCardCertificationCell class] forCellReuseIdentifier:NSStringFromClass([IDCardCertificationCell class])];
        [_listView registerClass:[OnionCertificationProgressCell class] forCellReuseIdentifier:NSStringFromClass([OnionCertificationProgressCell class])];
        
        _listView.backgroundColor = UIColorFromRGB(0xF5F7F5);
        [_listView setSeparatorColor:UIColorFromRGB(0xE9EEE7)];

    }
    return _listView;
}
@end

